package com.sgb.kjwl.view.ui.adapter.home;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.sgb.kjwl.BR;
import com.sgb.kjwl.R;
import com.sgb.kjwl.model.entity.DemandGoodsEntity;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;

import java.util.List;

public class AddGoodsAdapter extends BaseRecycleAdapter<DemandGoodsEntity> {

    private TextView tv_num;
    private TextView tv_line;

    public AddGoodsAdapter(Context context, List<DemandGoodsEntity> datas) {
        super(context, R.layout.item_add_goods, datas);
    }

    @Override
    public void convert(ItemViewHolder holder, final DemandGoodsEntity entity) {
        holder.setBinding(BR.viewModel, entity);
        tv_num = holder.itemView.findViewById(R.id.tv_num);
        tv_line = holder.itemView.findViewById(R.id.tv_line);
        if(entity.getUnit()!=null){
            tv_num.setText("数量：" + entity.getNum() +" / "+entity.getUnit());
        }else {
            tv_num.setText("数量：" + entity.getNum());
        }

        if(holder.getAdapterPosition() == 0){
            tv_line.setVisibility(View.GONE);
        }

    }
}
